/**
 * 
 */
package cn.jdbc.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import cn.jdbc.pojo.Reply_detail;
import cn.jdbc.service.reply.ReplyService;

/**
 * @author 你始终不懂
 * 
 */
@Controller
public class ReplyController {
	@Resource
	private ReplyService replyService;
	@RequestMapping(value="/reply.html")
	public String replyPost(Model model,@RequestParam int invid){
		List<Reply_detail> replyList=replyService.getReplyList(invid);
		model.addAttribute("replyLists",replyList);
		return "Reply";
	}
	
	@RequestMapping(value = "/add.html", method = RequestMethod.GET)
	public String Replyadd(@ModelAttribute("rep") Reply_detail rep,@RequestParam(value="invid",required=false) Integer invid)throws RuntimeException {
		rep.setInvid(invid);
		return "addInvitation";
	}
	@RequestMapping(value = "/add.html", method = RequestMethod.POST)
	public String addReply(@ModelAttribute("rep") Reply_detail rep){
		System.out.println(rep.getInvid());
		System.out.println(rep.getAuthor());
		System.out.println(rep.getContent());
		if(replyService.addRely(rep)){
			return "redirect:/reply.html";
		}
		return "addInvitation";
	}
}
